cmake_minimum_required(VERSION 3.10)
project(LearnOpenGL)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


option(NITRO_EXAMPLES "Build examples" ON)
option(NITRO_SHARED_LIB "Build shared library" OFF)
option(NITRO_PYTHON_BINDING "Build Python binding" OFF)


if(${NITRO_SHARED_LIB})
    if(WIN32)
        message(FATAL "Shared library currently not supported on Windows")
    endif()
    
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    set(CMAKE_SKIP_BUILD_RPATH FALSE)
    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
    set(CMAKE_INSTALL_RPATH $ORIGIN)
endif()

if(${NITRO_PYTHON_BINDING})
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()


add_subdirectory("external/stb")
add_subdirectory("external/glad")
add_subdirectory("external/glfw")

include_directories("Renderer")
file(GLOB SRC "src/*.cpp")
add_library(Renderer STATIC ${SRC})
target_link_libraries(Renderer PUBLIC stb glad glfw)

# if(${NITRO_PYTHON_BINDING})
# add_subdirectory("binding")
# endif()

if(${NITRO_EXAMPLES})
file(GLOB EXAMPLES "example/*")
foreach(EXAMPLE ${EXAMPLES})
    add_subdirectory(${EXAMPLE})
endforeach()
endif()